﻿using UnityEngine;
using System.Collections;
using PureMVC.Patterns;
using PureMVC.Interfaces;
using System.Collections.Generic;
public class TestAppFacade : MonoBehaviour {

	public MenuView menuView;

	// Use this for initialization
	void Start () {
		IFacade app = MyFacade.getInstance ();
		//ViewFacade.getInstance();
		Debug.Log(typeof(ViewFacade).Name);
		
		IFacade the = Facade.GetInstance (typeof(MyFacade).Name);
		if (app == the) {
			Debug.Log ("==");
		} else {
			Debug.Log ("!=");
		}

		
		app.RegisterCommand ("aaa", typeof (TestCommand));

		app.RegisterMediator (new TestMediator ());
		menuView.OnRegisterMediator(app);

		app.SendNotification ("aaa");
	}
	
	// Update is called once per frame
	void Update () {
	
	}
}


public class TestCommand : SimpleCommand {
	public override void Execute (INotification notification)
	{
		base.Execute (notification);
		Debug.Log ("TestCommand");
	}
}

public class TestMediator: Mediator {

	public override IEnumerable<string> ListNotificationInterests {
		get {
			return new List<string> () {
				"aaa"
			};
		}
	}

	public override void HandleNotification (INotification notification)
	{
		base.HandleNotification (notification);
		if (notification.Name == "aaa") {
			Debug.Log ("TestMediator");
		}
	}
}